package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 攻略文章信息
 */
@Setter
@Getter
public class StrategyDetail extends BaseDomain {
    public static final int STATE_NOMAL = 0;//草稿
    public static final int STATE_RELEASE = 1;//发布

    private String title;//标题

    private Date createTime;//创建时间

    private Date releaseTime;//发布时间

    private Integer sequence;//序号

    private StrategyCatalog catalog;//所属攻略分类

    private String coverUrl;//封面

    private Integer state;//状态

    private StrategyContent strategyContent;//攻略文章内容

    //获取json数据
    public String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("title", title);
        map.put("sequence", sequence);
        map.put("state", state);
        map.put("coverUrl", coverUrl);
        //所属攻略分类
        if (catalog != null) {
            map.put("catalogId", catalog.getId());
            //大攻略对象
            if (catalog.getStrategy() != null) {
                map.put("strategyId", catalog.getStrategy().getId());
            }
        }
        return JSONUtil.toJSONString(map);
    }
}